#ifndef CV_WINDOW_WRAPPER_H
#define CV_WINDOW_WRAPPER_H

#include <highgui.h>
#include <string>

class cv_window_wrapper
{
  std::string name_;

public:
  cv_window_wrapper(const std::string& name, int flags=CV_WINDOW_AUTOSIZE)
  {
    this->name_ = name;
    cvNamedWindow(name_.c_str(), flags);
  }
  ~cv_window_wrapper()
  {
    cvDestroyWindow(name_.c_str());
  }

  const std::string& name() const
  {
    return name_;
  }

  void show(const CvArr* image) const
  {
    cvShowImage(name_.c_str(), image);
  }

  void show(const cv::Mat& image) const
  {
    imshow(name_.c_str(), image);
  }

  void set_mouse_callback(cv::MouseCallback onMouse, void* par = (void*)0) const
  {
    cv::setMouseCallback(name_.c_str(), onMouse, par);
  }

  void create_trackbar(const std::string& trackbar_name, const char* window_name,
                      int* value, int count, cv::TrackbarCallback on_change )
  {
    cv::createTrackbar((name_ + trackbar_name).c_str(), name_.c_str(), value, count, on_change);
  }
};

#endif
